#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<string> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }

    int flag1 = 1, flag2 = 1;
    for (int i = 0; i < v.size() - 1; ++i)
    {
        if (v[i] > v[i + 1])
            flag1 = 0;
        if (v[i].size() > v[i + 1].size())
            flag2 = 0;
    }
    if (flag1 && flag2)
        cout << "both" << endl;
    else if (flag1)
        cout << "lexicographically" << endl;
    else if (flag2)
        cout << "lengths" << endl;
    else
        cout << "none" << endl;
    return 0;
}